Skip to content

Conversation

@cffls
Copy link
Contributor

@cffls cffls commented Jan 30, 2026

Description

Fix detected race conditions.
Also added a nightly github action that runs race condition check.

Changes

  • Bugfix (non-breaking change that solves an issue)
  • Hotfix (change that solves an urgent issue, and requires immediate attention)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (change that is not backwards-compatible and/or changes current functionality)
  • Changes only for a subset of nodes

Breaking changes

Please complete this section if any breaking changes have been made, otherwise delete it

Nodes audience

In case this PR includes changes that must be applied only to a subset of nodes, please specify how you handled it (e.g. by adding a flag with a default value...)

Checklist

  • I have added at least 2 reviewer or the whole pos-v1 team
  • I have added sufficient documentation in code
  • I will be resolving comments - if any - by pushing each fix in a separate commit and linking the commit hash in the comment reply
  • Created a task in Jira and informed the team for implementation in Erigon client (if applicable)
  • Includes RPC methods changes, and the Notion documentation has been updated

Cross repository changes

  • This PR requires changes to heimdall
    • In case link the PR here:
  • This PR requires changes to matic-cli
    • In case link the PR here:

Testing

  • I have added unit tests
  • I have added tests to CI
  • I have tested this code manually on local environment
  • I have tested this code manually on remote devnet using express-cli
  • I have tested this code manually on amoy
  • I have created new e2e tests into express-cli

Manual tests

Please complete this section with the steps you performed if you ran manual tests for this functionality, otherwise delete it

Additional comments

Please post additional comments in this section if you have them, otherwise delete it

Also added a nightly github action that runs race condition check
@claude
Copy link

claude bot commented Jan 30, 2026

Code Review

Found 2 issues that should be addressed:

1. triedb/database.go:121-122 - Potential panic with atomic.Value.Store(nil)

The SetReadBackend function now uses atomic.Value.Store(), but according to Go documentation, atomic.Value.Store(nil) panics. The code at core/blockchain.go:3164 calls SetReadBackend(nil), which will cause a runtime panic.

Suggested fix: Either add nil protection in SetReadBackend(), or use atomic.Pointer[backend] which supports nil values.

2. core/txpool/locals/journal.go:77-78 - Incomplete race condition fix

The PR adds mutex protection to setupWriter(), insert(), rotate(), and close(), but the load() function still accesses journal.writer directly without holding the mutex:

journal.writer = new(devNull)
defer func() { journal.writer = nil }()

This creates inconsistent synchronization - the load() function writes to journal.writer while other methods read/write it under mutex protection. During load(), the callback invokes TrackAll() which calls insert() under the mutex, creating a race between load()'s unprotected access and insert()'s protected access.

Suggested fix: Add mutex protection around the journal.writer accesses in load().


CLAUDE.md reference: Race Conditions guideline - "Use -race flag, protect shared state"

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot

See analysis details on SonarQube Cloud

@codecov
Copy link

codecov bot commented Jan 30, 2026

Codecov Report

❌ Patch coverage is 81.81818% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.56%. Comparing base (0caee33) to head (3c1c05e).
⚠️ Report is 3 commits behind head on develop.

Files with missing lines Patch % Lines
triedb/database.go 0.00% 4 Missing ⚠️

❌ Your patch status has failed because the patch coverage (81.81%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2027      +/-   ##
===========================================
- Coverage    49.57%   49.56%   -0.01%     
===========================================
  Files          874      874              
  Lines       150499   150517      +18     
===========================================
- Hits         74605    74601       -4     
- Misses       70856    70879      +23     
+ Partials      5038     5037       -1     
Files with missing lines Coverage Δ
core/txpool/locals/journal.go 65.27% <100.00%> (+4.96%) ⬆️
triedb/database.go 14.36% <0.00%> (ø)

... and 17 files with indirect coverage changes

Files with missing lines Coverage Δ
core/txpool/locals/journal.go 65.27% <100.00%> (+4.96%) ⬆️
triedb/database.go 14.36% <0.00%> (ø)

... and 17 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cffls cffls merged commit ed902e3 into develop Jan 30, 2026
19 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants